<?php
class UserAction extends BaseAction{
	public function login(){
		if(!$_POST){
			$this->display();
		}else{
			$login_info = Think::instance('UserCheck')->login();
			if($login_info['flag']){
				$this->redirect('Index/index');
			}else{
				$this->assign('jumpURL',U('User/login'));
				$this->error($login_info['msg']);
			}
			
		}
	}
	public function logout(){
		Think::instance('UserCheck')->logout();
		$this->redirect('Index/index');
	}
	public function register(){
		$this->assign('jumpUrl',U('user/register'));
		if($_POST['password']!=$_POST['password_repeat'])$this->error('两次密码必须相同');
		if($_POST){
			$User = D('User');
			if($User->create()){
				$User->add();
				$this->assign('jumpURL',U('User/login'));
				$this->success('注册成功');
			}else{
				$this->error($User->geterror());
			}
		}else{
			$this->display();exit;
		}

	}
}
?>